package com.cenntro.oss.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cenntro.common.base.BaseController;
import com.cenntro.common.util.result.Result;
import com.cenntro.oss.model.qo.DevTransferQO;
import com.cenntro.oss.model.vo.TransferListVO;
import com.cenntro.oss.service.DevTransferRecordLogService;

@RestController
@RequestMapping("/transfer")
public class DevTransferRecordLogController extends BaseController {

	@Resource
	private DevTransferRecordLogService devTransferRecordLogService;

	/**
	 * 
	* @Title list
	* @Description 过户车辆列表查询
	* @param agentId
	* @return  transferList
	* @throws
	 */
	@CrossOrigin
	@RequestMapping(value = "/list")
	public Result list(Integer agentId) {
		if (agentId == null) {
			return Result.error("参数不能为空");
		} else {
			List<TransferListVO> transferList = devTransferRecordLogService.selectTransferList(agentId);
			return Result.ok(transferList);
		}
	}

	/**
	 * 
	* @Title add
	* @Description 新增过户车辆 
	* @param qo
	* @return  
	* @throws
	 */
	@CrossOrigin
	@RequestMapping(value = "/add")
	public Result add(DevTransferQO qo) {
		int transfer = devTransferRecordLogService.insertTransfer(qo);
		if (transfer != 0) {
			return Result.ok();
		}
		return Result.error("所属车辆不再该机构下");
	}

}
